/**
 * @file setjmp.c
 * @author your name (you@domain.com)
 * @brief setjmp/longjmp 函数使用示例
 * @version 0.1
 * @date 2023-06-26
 * 
 * @copyright Copyright (c) 2023
 * 
 */
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>

static jmp_buf buf;

static void hello(void)
{
    printf("hello world\n");
    longjmp(buf, 1);
    printf("Nice to meet you\n");
}

int main(void)
{
    if (0 == setjmp(buf)) {
        printf("First return\n");
        hello();
    } else {
        printf("Second return\n");
    }
    exit(0);
}